﻿using System;
using System.Collections.Generic;

using E.Enum;
using E.BLL;
using E.Model;
using E.Web.UI.Page;

using X.Common;

namespace E.Web.Teacher.exam
{
    public partial class ScoreView : TeacherBasePage
    {
        public IList<ShortScoreModel> list;
        //public IDictionary<EnumScoreCategory, string> scoreList;
        public System.Text.StringBuilder sb = new System.Text.StringBuilder();
        public IList<ScoreCategoryModel> scoreList;

        protected override void ShowPage()
        {
            int userid = XRequest.GetInt("id",-1);
            //userid = 49;
            if (userid != -1)
            {

                ExamBLL bll = new ExamBLL();
                list = bll.GetUserCourseScoreList(userid);
                //scoreList = EnumClass.GetScoreCategoryList();
                scoreList = bll.GetScoreCategoryList();

                decimal total = 0;

                foreach (ScoreCategoryModel model in scoreList)
                {
                    sb.Append("<div class=\"s_rows\">\r\n");
                    sb.Append("  <div class=\"s_r_sc\">" + model.Name + "</div>\r\n");

                    decimal c = 0;

                    if (model.IsInput)
                    {
                        int score = bll.GetSetScore(userid, model.ID);
                        //sb.Append("  <div class=\"s_r_sco\">" + score + "_" + Math.Round((decimal)score * model.Scale / 100, 2) + "</div>\r\n");
                        c = Math.Round((decimal)score * model.Scale / 100, 2);
                        sb.Append("  <div class=\"s_r_sco\">" + c + "</div>\r\n");
                        sb.Append("  <div class=\"s_r_sd\">&nbsp;</div>\r\n");
                        sb.Append("  <div class=\"s_r_sv\">&nbsp;</div>\r\n");
                    }
                    else
                    {
                        if (model.IsCourse)
                        {
                            IList<int> sList = bll.GetUserCourseScore(userid);
                            int totalScore = 0;
                            foreach (int i in sList)
                            {
                                totalScore += i;
                            }
                            //sb.Append("  <div class=\"s_r_sco\">" + totalScore + "_" + Math.Round((decimal)(totalScore) * model.Scale / 50, 2) + "</div>\r\n");
                            c = Math.Round((decimal)(totalScore) * model.Scale / 50, 2);
                            sb.Append("  <div class=\"s_r_sco\">" + c + "</div>\r\n");
                            sb.Append("  <div class=\"s_r_sd\">&nbsp;</div>\r\n");
                            sb.Append("  <div class=\"s_r_sv\">&nbsp;</div>\r\n");
                        }
                        else
                        {
                            ShortScoreModel ssmodel = bll.GetCertificateScore(userid, areaid);
                            if (ssmodel.ID != -1)
                            {
                                //sb.Append("  <div class=\"s_r_sco\">" + ssmodel.Score + "_" + Math.Round((decimal)(ssmodel.Score) * model.Scale / 100, 2) + "</div>\r\n");
                                c = Math.Round((decimal)(ssmodel.Score) * model.Scale / 100, 2);
                                sb.Append("  <div class=\"s_r_sco\">" + c + "</div>\r\n");
                                sb.Append("  <div class=\"s_r_sd\">" + ssmodel.StartTime.ToString("yyyy.MM.dd") + "</div>\r\n");
                                sb.Append("  <div class=\"s_r_sv\"><a href=\"#?id=\"" + ssmodel.ID + "\"\">查看</a></div>\r\n");
                            }
                            else
                            {
                                sb.Append("  <div class=\"s_r_sco\">0</div>\r\n");
                                sb.Append("  <div class=\"s_r_sd\">&nbsp;</div>\r\n");
                                sb.Append("  <div class=\"s_r_sv\">&nbsp;</div>\r\n");
                            }
                        }
                    }
                    total += c;

                    sb.Append("</div>\r\n");
                }

                sb.Append("</div>\r\n");
                sb.Append("<div class=\"s_rows\" style=\"text-align:left;\">总分：" + total + "</div>\r\n");
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {

        }
    }
}

